using System;
using System.Xml;

namespace XNASpriteLib
{
	class Set
	{
		private readonly String name;
		private readonly double fpsMultiplier = 1.0;

		public Set(String name, double fpsMultiplier)
		{
			this.name = name;
			this.fpsMultiplier = fpsMultiplier;
		}


		/// <summary>
		/// Loads this set from an XML node
		/// </summary>
		/// <param name="node">The set node</param>
		public Set(XmlNode node)
		{
			if(node == null)
			{
				throw new ArgumentNullException("node", "State could not be loaded because the XML node was null");
			}
			else if(node.Attributes == null)
			{
				throw new ArgumentException("State could not be loaded because the XML node's Attributes are null");
			}


			if(node.Attributes["name"] != null)
			{
				name = node.Attributes["name"].Value;
			}
			else
			{
				throw new ArgumentException("State could not be loaded because the state does not have a name");
			}


			if (node.Attributes["fpsMultiplier"] != null)
			{
				String tmp = node.Attributes["fpsMultiplier"].Value;
				if (!double.TryParse(tmp, out fpsMultiplier))
				{
					fpsMultiplier = 1.0;
				}
			}
			else
			{
				fpsMultiplier = 1.0;
			}
		}
		
		public String Name
		{
			get{ return name; }
		}
		
		public double FPSMultiplier
		{
			get{ return fpsMultiplier; }
		}
	}
}
